import os

import gui
import tvdb
import notificator
import pluginmanager
import updater

class PyTv(object):

    def __init__(self):
        self.images = {'pytv':os.getcwd() + '/pytv.png',
                        'calendar':os.getcwd() + '/cal.png',
                        'update':os.getcwd() + '/update.png'}
        self.dire = os.getcwd() + '/.config/pytv/'
        self.pluginFolder = self.dire + 'plugins/'
        
        #Create DB manager instance
        tvdb.TvDB.dire = self.dire
        self.db = tvdb.TvDB()
        
        #Create Notificator instance
        notificator.Notificator.image = self.images['pytv']
        notificator.Notificator.dire = self.dire
        self.notif = notificator.Notificator()
        
        #Load Plugins
        self.plugins = pluginmanager.PluginManager(self)
        #Add plugins to Notificator
        notificator.Notificator.plugins = self.plugins
        
        #Update PyTv
        urlUpdate = 'http://plugin.pytv-series.googlecode.com/hg/version'
        self.update = updater.Updater()
        self.update.configure(os.getcwd(), urlUpdate, self.notif, self.dire, 'amd64')
        self.update.execute = self.update.check
        self.update.start()
        
        #Start the execution of Notificator
        self.notif.start()

        gui.setup(self)


def main():
    pytv = PyTv()

if __name__ == '__main__':
    main()
